<{include file="public/header" /}>
<body>

<div style="padding: 10px; background-color: #F2F2F2;padding-bottom: 150px">
  <form class="layui-form layui-form-pane" lay-filter="editform">
  	<div class="layui-card">
  		<!-- <div class="layui-card-header">请毕业生如实认真填写</div> -->
  		  <div class="layui-card-body">

  			  <div class="layui-form-item">
  			    <label class="layui-form-label">用户名</label>
  			    <div class="layui-input-block">
  			      <input type="text" name="uname" autocomplete="off" placeholder="" class="layui-input" lay-verify="required">
  			    </div>
  			  </div>

          <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
              <input type="text" name="truename" autocomplete="off" placeholder="" class="layui-input" lay-verify="required">
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
              <input type="password" name="pass" autocomplete="off" placeholder="" class="layui-input" lay-verify="required">
            </div>
          </div>

         <div class="layui-form-item">
            <label class="layui-form-label">权限身份</label>
            <div class="layui-input-block">
              <select name="admintype" lay-filter="aihao" lay-verify="required">
                <option value=""></option>
                <option value="1">教师</option>
                <option value="2">管理员</option>
              </select>
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">科目</label>
            <div class="layui-input-block">
              <select name="subject"  lay-verify="required">
                <option value=""></option>
                <option value="1">语文</option>
                <option value="2">数学</option>
                <option value="3">英语</option>
                <option value="4">物理</option>
                <option value="5">化学</option>
                <option value="6">生物</option>
                <option value="7">政治</option>
                <option value="8">历史</option>
                <option value="9">地理</option>
                
              </select>
            </div>
          </div>

          <div class="layui-form-item">
            <label class="layui-form-label">年级</label>
            <div class="layui-input-block">
              <select name="grade" lay-filter="aihao" lay-verify="required">
                <option value=""></option>
                <option value="1">高一</option>
                <option value="2">高二</option>
                <option value="3">高三</option>
                
              </select>
            </div>
          </div>

          
          <div class="layui-form-item">
            <label class="layui-form-label">班级</label>
            <div class="layui-input-block">
              <input type="text" name="class" autocomplete="off" placeholder="" class="layui-input" lay-verify="number">
            </div>
          </div>

         
  			
  		</div>
  	 </div>
    <div class="layui-card" style="padding-top: 15px;">
      <!-- <div class="layui-card-header">卡片面板</div> -->
      <div class="layui-card-body">

        <!-- <div class="layui-form-item">
            <input type="hidden" name="img" id="upimgurl" value="">
        </div> -->
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit="" type = "button" lay-filter="demo2" id="demo2">提交</button>
        </div>
      </div>
    </div>
  </form>
</div>



<script>

layui.use(['form','element','layer','jquery'], function(){
  var $ = layui.$
  ,form = layui.form,element = layui.element,layer = layui.layer;
  //----------上面引入layui下面开始业务，分割一下-----------------//
   //监听表单提交
  form.on('submit(demo2)', function(data){
    // layer.alert(JSON.stringify(data.field), {
    //   title: '最终的提交信息'
    // });
        var dayhour = getDaysBetween(data.field.starttime,data.field.endtime);
        layer.confirm('确定提交?', {btn: ['提交','取消'],btnAlign: 'c', title:'请确认'}
        ,function(index){
          //do something
          var id='<{$tdata.tid}>';
            $.post("<{:url('do_edit')}>",{id:id,data:data.field},function(data,status){
              //alert(data);
              //alert(JSON.stringify(data));
              //console(data);
              if(data===1){
                //layer.close(index);
                //parent.layer.closeAll('iframe');
                layer.msg('修改成功！',{icon: 6,time:1000},function(){
                  x_father_close();
                   parent.location.reload();
                }); 
              }else{
                //layer.close(index);
                layer.alert('修改失败，请刷新重试！',{icon:5,btn:'刷新'},function(index){layer.close(index);window.location.reload()});
              }
           })
          
        }
      //   ,function(){
      //     //点击取消的返回值
      //     //layer.msg('quxiao')
      //     window.location.reload()
      // }
      );  
   });

  //初始化数据
  form.val("editform", {
    "uname":"<{$tdata['uname']}>"// "name": "value"
    ,"truename": "<{$tdata['truename']}>"
    ,"grade": "<{$tdata['grade']}>"
    ,"pass": "<{$tdata['pass']}>"
    ,"class": "<{$tdata['class']}>"
    ,"admintype": "<{$tdata['admintype']}>"
    ,"subject": "<{$tdata['subject']}>"
    
  }) 
  
});


</script>


</body>
</html>